package com.duan.blog.common;

import com.duan.blog.constants.CodeEnum;
import lombok.AllArgsConstructor;
import lombok.Data;
import java.io.Serializable;

@Data
@AllArgsConstructor
public class RespUtil implements Serializable {

    private int code;
    private String msg;
    private Object data;


    public static RespUtil success(Object data){
        return new RespUtil(CodeEnum.SUCCESS.getCode(), CodeEnum.SUCCESS.getMsg(), data);
    }

    public static RespUtil success(int code, String msg, Object data){
        return new RespUtil(code, msg, data);
    }

    public static RespUtil fail(CodeEnum codeEnum){
        return new RespUtil(codeEnum.getCode(), codeEnum.getMsg(), null);
    }

}
